# set1 = {1, 2, 3, 4, 5, 4, 3,3} # 重复的就没了
# print(set1)
# set2 = {'banana', 'pitaya', 'apple', 'apple', 'banana', 'grape'}
# print(set2)
# set4 = set([1, 2, 2, 3, 3, 3, 2, 1])
# print(set4)
# set5 = {num for num in range(1, 20) if num % 3 == 0 or num % 7 == 0}
# print(set5)
# set11 = {'Python', 'C++', 'Java', 'Kotlin', 'Swift'}
# for i in set11:
#     print(i)
# set1 = {1, 2, 3, 4, 5, 6, 7}
# set2 = {2, 4, 6, 8, 10}
# 交集
# print(set1 & set2)                      # {2, 4, 6}
# print(set1.intersection(set2))          # {2, 4, 6}
# # 并集
# print(set1 | set2)  # {1, 2, 3, 4, 5, 6, 7, 8, 10}
# print(set1.union(set2)) # {1, 2, 3, 4, 5, 6, 7, 8, 10}
#
# # 差集 也就是set1 里的元素存在于set2中得去掉 形成新的集合
# print(set1 - set2)
# print(set1.difference(set2))
# # 对称差  symmetric_difference() 方法返回两个集合中不重复的元素集合，即会移除两个集合中都存在的元素。
# print(set1 ^ set2)                      # {1, 3, 5, 7, 8, 10}
# print(set1.symmetric_difference(set2))  # {1, 3, 5, 7, 8, 10}
# set1 |= set2
# print(set1)
set1 = {1, 10, 100}
# 添加元素
set1.add(1000)
set1.add(10000)
set1.add(10099)
print(set1)

# 删除元素
set1.discard(10)
if 100 in set1:
    set1.remove(100)
print(set1)  # {1, 1000, 10000}

# 清空元素
set1.clear()
print(set1)  # set()